# 供应商档案处理
from api_setting import *
from dim_api_auto_test.DimAPI.core.request_client import RestClient
from dim_api_auto_test.DimAPI.search import Search


class SupplierBillDeal(RestClient):
    def __init__(self, **kwargs):
        super(SupplierBillDeal, self).__init__(**kwargs)
        self.search = Search()

    def delete_supplier_bill(self):
        """
        删除供应商档案处理单据
        :return:
        """
        url = DELETE_SUPPLIER_BILL_URL
        # 查询状态为“待审核”的单据，获取第1个单据的id
        bill_id = self.search.search_supplier_bill("PENDING")["data"]["list"][0]["id"]
        params = {"id": bill_id, "invalidReason": "测试作废供应商档案处理单据"}
        r = self.post(url=url, params=params)
        return r.content


if __name__ == "__main__":
    test = SupplierBillDeal()
    result = test.delete_supplier_bill()
    print(result)
